###############################################################################
# SuperLinks                                                                  #
# Written by Gregory Nolle (greg@nolle.co.uk)                                 #
# Copyright 2000-2003 by PlasmaPulse Solutions (http://www.plasmapulse.com)   #
###############################################################################
# Output/Add.pm.pl -> Add module                                              #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::Add;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = ("input" => {}, "error" => "", @_);

  #----------------------------------------------------------------------#
  # Preparing data...                                                    #

  my %FIELDS;
  
  $FIELDS{'categories'} = $in{'input'}->{'CATEGORIES'};
  $FIELDS{'error'}      = &Standard::ProcessError(LANGUAGE => "Add", ERROR => $in{'error'});

  foreach my $category (@{ $in{'input'}->{'CATEGORIES'} }) {
    $category->{'extra'} = eval($category->{'EXTRA'});
  }

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  return &Standard::Substitute(
    INPUT     => "Add.htm",
    STANDARD  => 1,
    FIELDS    => \%FIELDS
  );
}

###############################################################################
# do subroutine
sub do {
  my $self = shift;
  my %in = (input => undef, @_);

  #----------------------------------------------------------------------#
  # Preparing data...                                                    #

  my %FIELDS;
  
  $FIELDS{'category'} = $in{'input'}->{'CATEGORY'};
  $FIELDS{'record'}   = $in{'input'}->{'RECORD'};

  $in{'input'}->{'CATEGORY'}->{'extra'} = eval($in{'input'}->{'CATEGORY'}->{'EXTRA'});

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  return &Standard::Substitute(
    INPUT     => "DoAdd.htm",
    STANDARD  => 1,
    FIELDS    => \%FIELDS
  );
}

###############################################################################
# email subroutine
sub email {
  my $self = shift;
  my %in = (type => "", input => undef, @_);

  #----------------------------------------------------------------------#
  # Preparing data...                                                    #

  my %FIELDS;
  
  $FIELDS{'category'} = $in{'input'}->{'CATEGORY'};
  $FIELDS{'record'}   = $in{'input'}->{'RECORD'};

  $in{'input'}->{'CATEGORY'}->{'extra'} = eval($in{'input'}->{'CATEGORY'}->{'EXTRA'});

  #----------------------------------------------------------------------#
  # Printing email...                                                    #

  my $LANGUAGE = &Standard::GetLanguage("Add");
  
  my %Return;

  if ($in{'type'} eq "admin") {
    $Return{'MESSAGE'} = &Standard::Substitute(
      INPUT     => "Emails/DoAdd-Admin.txt",
      STANDARD  => 1,
      FIELDS    => \%FIELDS
    );
    $Return{'TO'} = $GENERAL->{'ADMIN_EMAIL'};
    $Return{'SUBJECT'} = &Standard::Substitute(
      INPUT     => \$LANGUAGE->{'EMAILSUBJECT-ADMIN'},
      STANDARD  => 1,
      FIELDS    => \%FIELDS
    );
    $Return{'HTML'} = $GENERAL->{'HTML_IN_ADMIN_EMAILS'};
  } else {
    $Return{'MESSAGE'} = &Standard::Substitute(
      INPUT     => "Emails/DoAdd-User.txt",
      STANDARD  => 1,
      FIELDS    => \%FIELDS
    );
    $Return{'TO'} = $in{'input'}->{'RECORD'}->{'CONTACT_EMAIL'};
    $Return{'SUBJECT'} = &Standard::Substitute(
      INPUT     => \$LANGUAGE->{'EMAILSUBJECT-USER'},
      STANDARD  => 1,
      FIELDS    => \%FIELDS
    );
    $Return{'HTML'} = $GENERAL->{'HTML_IN_USER_EMAILS'};
  }

  return %Return;
}

1;